const photoUtils = {
  /**
   * 打开相册
   * 需要安装 cordova-plugin-camera 插件
   * 返回base64字符串
   */
  openAlbum () {
    return new Promise((resolve, reject) => {
      navigator.camera.getPicture(data => {
        resolve(data)
      }, error => {
        reject(0)
      }, {
        quality: 50, // 图片质量 0 - 100, 默认值50
        destinationType: 0, // 0-返回base64编码字符串 1-返回图片url
        sourceType: 0 // 0-打开照片库 1-打开本机相机 2-已保存的相册
      })
    })
  },
  /**
   * 拍照
   * 需要安装 cordova-plugin-camera 插件
   * 返回base64字符串
   * */
  takePhoto () {
    return new Promise((resolve, reject) => {
      navigator.camera.getPicture(data => {
        resolve(data)
      }, error => {
        reject(0)
      }, {
        quality: 50,
        destinationType: 0,
        sourceType: 1
      })
    })
  }
}

export default photoUtils
